import axios from "axios"

export const bookAll = async (keyword) => {
    let data
    if (keyword) {
        data = await axios.get(`http://localhost:8080/book?keyword=${keyword}`)
    }
    else {
        data = await axios.get(`http://localhost:8080/book`)
    }
    return data.data
}

export const bookDel = async (id) => {
    let data = await axios.delete(`http://localhost:8080/book/${id}`)
    return data
}


export const bookAdd = async (obj) => {
    let data = await axios.post(`http://localhost:8080/book`,obj)
    return data
}

export const bookOne = async (id) => {
    let data = await axios.get(`http://localhost:8080/book/${id}`)
    return data.data[0]
}

export const bookUpdate = async (id,obj) => {
    let data = await axios.put(`http://localhost:8080/book/${id}`,obj)
    return data
}
